home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 25 / Cream of the Crop 25.iso / program / ny_src.zip / NYIBBS.CPP < prev    next >
C/C++ Source or Header  |  1997-04-22  |  53KB  |  1,815 lines

  1. #include "ny2008.h"
  2.  
  3. tIBInfo IBBSInfo;
  4. extern int ibbsi;
  5. extern int ibbsi_operator;
  6. extern int ibbsi_game_num;
  7. extern char bbs_namei[];
  8. int ibbs_send_nodelist=FALSE;
  9. int ibbs_maint_i=FALSE;
  10. int ibbs_maint_o=FALSE;
  11. //int ibbs_i_mail=FALSE;
  12. //int ibbs_operator=FALSE;
  13. //int ibbs_game_num=0;
  14. struct ffblk fff;
  15. struct ffblk ff;
  16. //int time_slice_value=1500;
  17. char *ver="0.10";       //this is this module version which is 0.10 beta2
  18. char *verinfo="BETA 2";
  19. //char no_slices=FALSE;
  20. char single_node=FALSE;
  21.  
  22. /*void
  23. time_slice(void)
  24. {
  25.   asm {
  26.     mov ax,time_slice_value
  27.     int 15
  28.   }
  29. } */
  30.  
  31. char
  32. *LocationOf(char *address) {
  33.   int iCurrentSystem;
  34.   if(IBBSInfo.paOtherSystem == NULL && IBBSInfo.nTotalSystems != 0)
  35.     return(NULL);
  36.   for(iCurrentSystem = 0; iCurrentSystem < IBBSInfo.nTotalSystems;++iCurrentSystem) {
  37.     if(strcmp(IBBSInfo.paOtherSystem[iCurrentSystem].szAddress,address)==0) {
  38.       return(IBBSInfo.paOtherSystem[iCurrentSystem].szSystemName);
  39.     }
  40.   }
  41.   return(NULL);
  42. }
  43.  
  44.  
  45.  
  46. void
  47. AddBestPlayerInIB(char *name,unsigned long points,char location[])
  48. {
  49. //  ffblk ffblk;
  50.   ibbs_best_rec_type best_rec,best_rec2;
  51.   FILE *justfile;
  52.   int cnt=0,len_of_list;
  53.   strcpy(best_rec2.name,name);
  54.   strcpy(best_rec2.location,location);
  55.   best_rec2.points=points;
  56.  
  57.  
  58. //  ch_game_d();
  59.   if (findfirst("NYIBBEST.TEN",&fff,0)==0) {
  60.     justfile=ShareFileOpen("NYIBBEST.TEN","r+b");
  61.     len_of_list=filelength(fileno(justfile))/sizeof(ibbs_best_rec_type) +1;
  62.     if (len_of_list>10) len_of_list=10;
  63.  
  64.     /*check if the same record exists*/
  65.     while (cnt<10 && ny_fread(&best_rec,sizeof(ibbs_best_rec_type),1,justfile)==1) {
  66. //      printf("[%ld=%ld],",best_rec.points,points);
  67. //      printf("[%s=%s],",best_rec.location,location);
  68. //      printf("[%s=%s]\n",best_rec.name,name);
  69.       if (points==best_rec.points &&
  70.       strcmp(best_rec.location,location)==0 &&
  71.       strcmp(best_rec.name,name)==0) {
  72.     /*if it already exists quit this function*/
  73.     fclose(justfile);
  74.     return;
  75.       }
  76.     }
  77.  
  78.     /*rewind the file to beginning*/
  79.     fseek(justfile,0,SEEK_SET);
  80.  
  81.     while (cnt<10 && ny_fread(&best_rec,sizeof(ibbs_best_rec_type),1,justfile)==1) {
  82.  
  83.       if (points>=best_rec.points) {
  84.     //fseek(justfile,(long)cnt*sizeof(ibbs_best_rec_type),SEEK_SET);
  85.     //ny_fwrite(&best_rec2,sizeof(ibbs_best_rec_type),1,justfile);
  86.     strcpy(best_rec.name,best_rec2.name);
  87.     strcpy(best_rec.location,best_rec2.location);
  88.     best_rec.points=best_rec2.points;
  89.     //cnt++;
  90.     while (cnt<len_of_list) {
  91.       fseek(justfile,(long)cnt*sizeof(ibbs_best_rec_type),SEEK_SET);
  92.       ny_fread(&best_rec2,sizeof(ibbs_best_rec_type),1,justfile);
  93.       fseek(justfile,(long)cnt*sizeof(ibbs_best_rec_type),SEEK_SET);
  94.       ny_fwrite(&best_rec,sizeof(ibbs_best_rec_type),1,justfile);
  95.       strcpy(best_rec.name,best_rec2.name);
  96.       strcpy(best_rec.location,best_rec2.location);
  97.       best_rec.points=best_rec2.points;
  98.       cnt++;
  99.     }
  100.     fclose(justfile);
  101.     //od_control.od_ker_exec=NULL;
  102.     return;
  103.       }
  104.       cnt++;
  105.  
  106.     }
  107.  
  108.     fclose(justfile);
  109.     if (cnt<10) {
  110.       justfile=ShareFileOpen("NYIBBEST.TEN","a+b");
  111.       ny_fwrite(&best_rec2,sizeof(ibbs_best_rec_type),1,justfile);
  112.       fclose(justfile);
  113.       //od_control.od_ker_exec=NULL;
  114.       return;
  115.     } else {
  116.       //od_control.od_ker_exec=NULL;
  117.       return;
  118.     }
  119.   }
  120.   justfile=ShareFileOpen("NYIBBEST.TEN","wb");
  121.   ny_fwrite(&best_rec2,sizeof(ibbs_best_rec_type),1,justfile);
  122.   fclose(justfile);
  123.   //od_control.od_ker_exec=NULL;
  124.   return;
  125. }
  126.  
  127.  
  128.  
  129. void
  130. get_bbsname(char bbsname[])
  131. {
  132.   int cnt=0;
  133.   char out[36];
  134.   int cnto=0;
  135.  
  136.   while (bbsname[cnt]!=0 && cnto<35) {
  137.     if (bbsname[cnt]>='a' && bbsname[cnt]<='z') bbsname[cnt]-=32;
  138.  
  139.     if (bbsname[cnt]>='A' && bbsname[cnt]<='Z') {
  140.       out[cnto]=bbsname[cnt];
  141.       cnto++;
  142.     }
  143.  
  144.     cnt++;
  145.   }
  146.   out[cnto]=0;
  147.   strcpy(bbsname,out);
  148. }
  149.  
  150. int
  151. seereg(char bbsname[])
  152. {
  153.   return TRUE;
  154.  /*
  155.   FILE *justfile;
  156.  
  157.   char kod[26];
  158.   char string[26] = "ABECEDAKURVAHLEDAPICATAKY";
  159.   int intval;
  160.   int cnt;
  161.   int bbsc;
  162.   int which;
  163.   int temp,temp2;
  164.  
  165. //  ch_game_d();
  166.   justfile=ShareFileOpen("NYREG.KEY","rb");
  167.  
  168.   ny_fread(kod,26,1,justfile);
  169.  
  170.   fclose(justfile);
  171.  
  172.  
  173.   sscanf(kod,"%02d",&intval);
  174.  
  175.   if (intval!=strlen(bbsname)) {
  176.     return(0);
  177.   }
  178.  
  179.   intval = kod[0] - '0';
  180.  
  181.   bbsc=0;
  182.  
  183.   which=0;
  184.  
  185.   for (cnt=2;cnt<25;cnt++) {
  186.     if (bbsname[bbsc]==0) bbsc=0;
  187.  
  188.     temp2=string[cnt]+intval+bbsname[bbsc];
  189.  
  190. //    if (kod[cnt]>'Z') kod[cnt]-=('Z'-'A');
  191.     temp =  (temp2-'A')/('Z'-'A');
  192.  
  193.     temp2 = temp2 - (('Z'-'A') * temp);
  194.  
  195.     if (kod[cnt]!=temp2) {
  196.       return(0);
  197.     }
  198.  
  199.     if (which==0)
  200.       which =1;
  201.     else
  202.       which =0;
  203.  
  204.     intval = kod[which] - '0';
  205.     bbsc++;
  206.   }
  207.  
  208.   return(TRUE);*/
  209. }
  210.  
  211. void DecodeBuffer(const char *pszSource, char *pDestBuffer, int nBufferSize, int skip)
  212.    {
  213.    const char *pcSource = pszSource;
  214.    char *pcDest = (char *)pDestBuffer;
  215.    int iDestLocation;
  216.    tBool bFirstOfByte = TRUE;
  217.  
  218.    /* Search for beginning of buffer delimiter char, returning if not found */
  219.    while(*pcSource && *pcSource != DELIMITER_CHAR) ++pcSource;
  220.    if(!*pcSource) return;
  221.  
  222.    /* Move pointer to first char after delimiter char */
  223.    ++pcSource;
  224.    if(skip)
  225.      pcSource+=4;
  226.  
  227.    /* Loop until destination buffer is full, delimiter char is encountered, */
  228.    /* or end of source buffer is encountered */
  229.    iDestLocation = 0;
  230.    while(iDestLocation < nBufferSize && *pcSource
  231.     && *pcSource != DELIMITER_CHAR)
  232.       {
  233.       /* If this is a valid data character */
  234.       if(*pcSource >= 0x40 && *pcSource <= 0x7e)
  235.      {
  236.      /* If this is first character of byte */
  237.      if(bFirstOfByte)
  238.         {
  239.         *pcDest = *pcSource & 0x3f;
  240.  
  241.         /* Toggle bFirstOfByte */
  242.         bFirstOfByte = FALSE;
  243.         }
  244.      else /* if(!bFirstOfByte) */
  245.         {
  246.         *pcDest |= (*pcSource & 0x30) << 2;
  247.  
  248.         /* Increment destination */
  249.         ++iDestLocation;
  250.         ++pcDest;
  251.  
  252.         /* Toggle bFirstOfByte */
  253.         bFirstOfByte = TRUE;
  254.         }
  255.      }
  256.  
  257.       /* Increment source byte pointer */
  258.       ++pcSource;
  259.       }
  260.    }
  261.  
  262. int ReadLen(const char *pszSource)
  263. {
  264.   const char *pcSource = pszSource;
  265. //  char *pcDest;// = (char *)pDestBuffer;
  266.   char size[2];
  267. //  int iDestLocation;
  268.   int nBufferSize=2;
  269. //  tBool bFirstOfByte = TRUE;
  270.  
  271.   /* Search for beginning of buffer delimiter char, returning if not found */
  272.   while(*pcSource && *pcSource != DELIMITER_CHAR) ++pcSource;
  273.   if(!*pcSource) return(0);
  274.  
  275.   /* Move pointer to first char after delimiter char */
  276.   ++pcSource;
  277.  
  278.   size[0] = *pcSource & 0x3f;
  279.   pcSource++;
  280.   size[0] |= (*pcSource & 0x30) << 2;
  281.   pcSource++;
  282.   size[1] = *pcSource & 0x3f;
  283.   pcSource++;
  284.   size[1] |= (*pcSource & 0x30) << 2;
  285.   pcSource++;
  286.  
  287.   nBufferSize=*(int *)size;
  288. //  printf("&&&& %d &&&&\n",nBufferSize);
  289.   return(nBufferSize);
  290. }
  291.  
  292.  
  293. /*void
  294. DecodeBufferR(const char *pszSource, int *pDestBuffer, int nBufferSize)
  295. {
  296.   const char *pcSource = pszSource;
  297.   char *pcDest = (char *)pDestBuffer;
  298. //  char size[2];
  299.   int iDestLocation;
  300. //  int nBufferSize=2;
  301.   tBool bFirstOfByte = TRUE;
  302.  
  303.   /* Search for beginning of buffer delimiter char, returning if not found -/
  304.   while(*pcSource && *pcSource != DELIMITER_CHAR) ++pcSource;
  305.   if(!*pcSource) return(0);
  306.  
  307.   /* Move pointer to first char after delimiter char -/
  308.   ++pcSource;
  309.  
  310. /*  size[0] = *pcSource & 0x3f;
  311.   pcSource++;
  312.   size[0] |= (*pcSource & 0x30) << 2;
  313.   pcSource++;
  314.   size[1] = *pcSource & 0x3f;
  315.   pcSource++;
  316.   size[1] |= (*pcSource & 0x30) << 2;
  317.   pcSource++;
  318.  
  319.   nBufferSize=*(int *)size;
  320.   printf("&&&& %d &&&&\n",nBufferSize);
  321.   *pDestBuffer=(int)malloc(nBufferSize);
  322.   pcDest = (char *)(*pDestBuffer);*/
  323.  
  324.   /* Loop until destination buffer is full, delimiter char is encountered, -/
  325.   /* or end of source buffer is encountered -/
  326.   iDestLocation = 0;
  327.  
  328.   while(iDestLocation < nBufferSize && *pcSource && *pcSource != DELIMITER_CHAR) {
  329.     /* If this is a valid data character -/
  330.     if(*pcSource >= 0x40 && *pcSource <= 0x7e) {
  331.       /* If this is first character of byte -/
  332.       if(bFirstOfByte) {
  333. //      if(iDestLocation<2) {
  334. //        size = *pcSource & 0x3f;
  335. //        printf("#4#");
  336. //      } else
  337.     *pcDest = *pcSource & 0x3f;
  338.  
  339.     /* Toggle bFirstOfByte -/
  340.     bFirstOfByte = FALSE;
  341.       } else { /* if(!bFirstOfByte) -/
  342. //      if(iDestLocation<2) {
  343. //        size |= (*pcSource & 0x30) << 2;
  344. //        printf("#5#");
  345. //      } else {
  346.       *pcDest |= (*pcSource & 0x30) << 2;
  347.     ++pcDest;
  348.     printf("%c",*pcDest);
  349. //      }
  350.  
  351.     /* Increment destination -/
  352.     ++iDestLocation;
  353.  
  354.     /* Toggle bFirstOfByte -/
  355.     bFirstOfByte = TRUE;
  356.       }
  357.     //  printf("#5#");
  358. //      if(iDestLocation==2) {
  359. //      }
  360.     }
  361.     /* Increment source byte pointer -/
  362.     ++pcSource;
  363.   }
  364.   return(nBufferSize);
  365. }
  366. */
  367.  
  368. tIBResult IBGet(tIBInfo *pInfo, char *pBuffer, int nMaxBufferSize)
  369.    {
  370.    tIBResult ToReturn;
  371.    struct ffblk DirEntry;
  372.    DWORD lwCurrentMsgNum;
  373.    tMessageHeader MessageHeader;
  374.    char szFileName[PATH_CHARS + FILENAME_CHARS + 2];
  375.    char *pszText;
  376.    tFidoNode ThisNode,OtherNode;
  377.  
  378.    /* Validate information structure */
  379.    ToReturn = ValidateInfoStruct(pInfo);
  380.    if(ToReturn != eSuccess) return(ToReturn);
  381.  
  382.    /* Get this node's address from string */
  383.    ConvertStringToAddress(&ThisNode, pInfo->szThisNodeAddress);
  384.  
  385.    MakeFilename(pInfo->szNetmailDir, "*.msg", szFileName);
  386.  
  387.    /* Seach through each message file in the netmail directory, in no */
  388.    /* particular order.                                               */
  389.    if(findfirst(szFileName, &DirEntry, FA_ARCH) == 0)
  390.       {
  391.       do
  392.      {
  393.      lwCurrentMsgNum = atol(DirEntry.ff_name);
  394.  
  395.      /* If able to read message */
  396.      if(ReadMessage(pInfo->szNetmailDir, lwCurrentMsgNum, &MessageHeader,
  397.         &pszText))
  398.         {
  399. /*          od_printf("\nREAD THROUGH MESSAGE\n");
  400.         od_printf("|%s|\n\r",MessageHeader.szToUserName);
  401.         od_printf("|%s|\n\r",pInfo->szProgName);
  402.         od_printf("%d:",MessageHeader.wDestZone);
  403.         od_printf("%d/",MessageHeader.wDestNet);
  404.         od_printf("%d.",MessageHeader.wDestNode);
  405.         od_printf("%d\n\r",MessageHeader.wDestPoint);
  406.  
  407.         od_get_answer("1");*/
  408.         /* If message is for us, and hasn't be read yet */
  409.         ConvertStringToAddress(&OtherNode,&MessageHeader.szToUserName[3]);
  410.  
  411.         if(stricmp(MessageHeader.szFromUserName, pInfo->szProgName) == 0
  412.            && (ThisNode.wZone == OtherNode.wZone || OtherNode.wZone==0 || ThisNode.wZone==0)
  413.            && ThisNode.wNet == OtherNode.wNet
  414.            && ThisNode.wNode == OtherNode.wNode
  415.            && ThisNode.wPoint == OtherNode.wPoint
  416.            && !(MessageHeader.wAttribute & ATTRIB_RECEIVED))
  417.            {
  418.  
  419. /*             od_printf("\n\rUNREAD AND FOR US\n\r");
  420.            od_get_answer("1");*/
  421.  
  422.            /* Decode message text, placing information in buffer */
  423.            DecodeBuffer(pszText, pBuffer, nMaxBufferSize,FALSE);
  424.  
  425.            /* If received messages should be deleted */
  426.            if(pInfo->bEraseOnReceive)
  427.           {
  428.           /* Determine filename of message to erase */
  429.           GetMessageFilename(pInfo->szNetmailDir, lwCurrentMsgNum,
  430.                      szFileName);
  431.  
  432.           /* Attempt to erase file */
  433.           if(unlink(szFileName) == -1)
  434.              {
  435.              ToReturn = eGeneralFailure;
  436.              }
  437.           else
  438.              {
  439.              ToReturn = eSuccess;
  440.              }
  441.           }
  442.  
  443.            /* If received messages should not be deleted */
  444.            else /* if(!pInfo->bEraseOnReceive) */
  445.           {
  446.           /* Mark message as read */
  447.           MessageHeader.wAttribute |= ATTRIB_RECEIVED;
  448.           ++MessageHeader.wTimesRead;
  449.  
  450.           /* Attempt to rewrite message */
  451.           if(!WriteMessage(pInfo->szNetmailDir, lwCurrentMsgNum,
  452.            &MessageHeader, pszText))
  453.              {
  454.              ToReturn = eGeneralFailure;
  455.              }
  456.           else
  457.              {
  458.              ToReturn = eSuccess;
  459.              }
  460.           }
  461.  
  462.            /* Deallocate message text buffer */
  463.            free(pszText);
  464.  
  465.            /* Return appropriate value */
  466.            return(ToReturn);
  467.            }
  468.         free(pszText);
  469.         }
  470.      } while(findnext(&DirEntry) == 0);
  471.       }
  472.  
  473.    /* If no new messages were found */
  474.    return(eNoMoreMessages);
  475.    }
  476.  
  477. tIBResult IBGetLen(tIBInfo *pInfo, long *msgnum, int *nBufferLen)
  478.    {
  479.    tIBResult ToReturn;
  480.    struct ffblk DirEntry;
  481.    DWORD lwCurrentMsgNum;
  482.    tMessageHeader MessageHeader;
  483.    char szFileName[PATH_CHARS + FILENAME_CHARS + 2];
  484.    char *pszText;
  485.    tFidoNode ThisNode,OtherNode;
  486. //   int n;
  487.  
  488.    /* Validate information structure */
  489.    ToReturn = ValidateInfoStruct(pInfo);
  490.    if(ToReturn != eSuccess) return(ToReturn);
  491.  
  492.    /* Get this node's address from string */
  493.    ConvertStringToAddress(&ThisNode, pInfo->szThisNodeAddress);
  494.  
  495.    MakeFilename(pInfo->szNetmailDir, "*.msg", szFileName);
  496.  
  497.    /* Seach through each message file in the netmail directory, in no */
  498.    /* particular order.                                               */
  499.    if(findfirst(szFileName, &DirEntry, FA_ARCH) == 0)
  500.       {
  501.       do
  502.      {
  503.      lwCurrentMsgNum = atol(DirEntry.ff_name);
  504.      *msgnum = lwCurrentMsgNum;
  505.  
  506.      /* If able to read message */
  507.      if(ReadMessage(pInfo->szNetmailDir, lwCurrentMsgNum, &MessageHeader,
  508.         &pszText))
  509.         {
  510.         ConvertStringToAddress(&OtherNode,&MessageHeader.szToUserName[3]);
  511.  
  512.         if(stricmp(MessageHeader.szFromUserName, pInfo->szProgName) == 0
  513.            && (ThisNode.wZone == OtherNode.wZone || OtherNode.wZone==0 || ThisNode.wZone==0)
  514.            && ThisNode.wNet == OtherNode.wNet
  515.            && ThisNode.wNode == OtherNode.wNode
  516.            && ThisNode.wPoint == OtherNode.wPoint
  517.            && !(MessageHeader.wAttribute & ATTRIB_RECEIVED))
  518.            {
  519.  
  520.            /* Decode message text, placing information in buffer */
  521.            *nBufferLen=ReadLen(pszText);
  522.  
  523.            free(pszText);
  524.  
  525.            /* Return appropriate value */
  526.            return(ToReturn);
  527.            }
  528.         free(pszText);
  529.         }
  530.      } while(findnext(&DirEntry) == 0);
  531.       }
  532.  
  533.    /* If no new messages were found */
  534.    return(eNoMoreMessages);
  535.    }
  536.  
  537. int
  538. IBGetR(tIBInfo *pInfo, char *pBuffer, int nBufferLen, long lwCurrentMsgNum)
  539. {
  540. //   tIBResult ToReturn;
  541. //   struct ffblk DirEntry;
  542. //   DWORD lwCurrentMsgNum;
  543.    tMessageHeader MessageHeader;
  544.    char szFileName[PATH_CHARS + FILENAME_CHARS + 2];
  545. //   char numstr[FILENAME_CHARS + 2];
  546.    char *pszText;
  547. //   tFidoNode ThisNode,OtherNode;
  548. //   int n;
  549.  
  550.    /* Validate information structure */
  551. //   ToReturn = ValidateInfoStruct(pInfo);
  552. //   if(ToReturn != eSuccess) return(ToReturn);
  553.  
  554.    /* Get this node's address from string */
  555. //   ConvertStringToAddress(&ThisNode, pInfo->szThisNodeAddress);
  556.  
  557. //   sprintf(numstr,"%d.msg",msgnum);
  558.  
  559. //   MakeFilename(pInfo->szNetmailDir, numstr, szFileName);
  560.  
  561.    /* Seach through each message file in the netmail directory, in no */
  562.    /* particular order.                                               */
  563. //   if(findfirst(szFileName, &DirEntry, FA_ARCH) == 0)
  564. //      {
  565. //      printf("@5@");
  566. //      do
  567. //       {
  568. //       lwCurrentMsgNum = atol(DirEntry.ff_name);
  569.  
  570. //       printf("\n%s\n",DirEntry.ff_name);
  571.  
  572.      /* If able to read message */
  573.   if(ReadMessage(pInfo->szNetmailDir, lwCurrentMsgNum, &MessageHeader, &pszText)) {
  574.   /*  ConvertStringToAddress(&OtherNode,&MessageHeader.szToUserName[3]);
  575.  
  576.         printf("@6@");
  577.  
  578.         if(strcmp(MessageHeader.szFromUserName, pInfo->szProgName) == 0
  579.            && (ThisNode.wZone == OtherNode.wZone || OtherNode.wZone==0 || ThisNode.wZone==0)
  580.            && ThisNode.wNet == OtherNode.wNet
  581.            && ThisNode.wNode == OtherNode.wNode
  582.            && ThisNode.wPoint == OtherNode.wPoint
  583.            && !(MessageHeader.wAttribute & ATTRIB_RECEIVED))
  584.            {
  585.            printf("@7@");*/
  586.     /* Decode message text, placing information in buffer */
  587.     DecodeBuffer(pszText, pBuffer, nBufferLen,TRUE);
  588.     //*nBufferLen=DecodeBufferR(pszText, pBuffer);
  589.  
  590.     /* If received messages should be deleted */
  591.     if(pInfo->bEraseOnReceive) {
  592.       /* Determine filename of message to erase */
  593.       GetMessageFilename(pInfo->szNetmailDir, lwCurrentMsgNum, szFileName);
  594.  
  595.       /* Attempt to erase file */
  596.       if(unlink(szFileName) == -1) {
  597.     free(pszText);
  598.     return(FALSE);
  599.     //ToReturn = eGeneralFailure;
  600.       } //else {
  601.     //ToReturn = eSuccess;
  602. //      }
  603.     } else {        /* If received messages should not be deleted */
  604.             /* if(!pInfo->bEraseOnReceive) */
  605.       /* Mark message as read */
  606.       MessageHeader.wAttribute |= ATTRIB_RECEIVED;
  607.       ++MessageHeader.wTimesRead;
  608.  
  609.       /* Attempt to rewrite message */
  610.       if(!WriteMessage(pInfo->szNetmailDir, lwCurrentMsgNum, &MessageHeader, pszText)) {
  611.     free(pszText);
  612.     return(FALSE);
  613.     //ToReturn = eGeneralFailure;
  614.       } //else {
  615.        //       ToReturn = eSuccess;
  616. //      }
  617.     }
  618.  
  619.     /* Deallocate message text buffer */
  620.     free(pszText);
  621.  
  622.     /* Return appropriate value */
  623.     return(TRUE);
  624.   }
  625.   //free(pszText);
  626.  
  627. //       } while(findnext(&DirEntry) == 0);
  628. //      }
  629. //      printf("@10@");
  630.  
  631.    /* If no new messages were found */
  632.    return(FALSE);
  633. }
  634.  
  635. /*refreshes the ib best list according to local best list*/
  636. void
  637. RefreshBest(void)
  638. {
  639.   best_rec_type best_rec;
  640.   FILE *justfile;
  641.  
  642.   /*if best list exists*/
  643.   if (findfirst("NYBEST.TEN",&fff,0)==0) {
  644.     /*open for reading*/
  645.     justfile=ShareFileOpen("NYBEST.TEN","rb");
  646.     while(ny_fread(&best_rec,sizeof(best_rec),1,justfile)==1) {
  647.       AddBestPlayerInIB(best_rec.name,best_rec.points,IBBSInfo.szThisNodeAddress);
  648.     }
  649.     fclose(justfile);
  650.   }
  651. }
  652.  
  653.  
  654.  
  655. int
  656. main(int argc,char *argv[])
  657. {
  658.   FILE *justfile,*njustfile;
  659. //  char key;
  660. //  unsigned int uintval;
  661.   char numstr[26];
  662. //  scr_rec srec;
  663.   int cnt,x;//,intval,x;
  664.   int n;
  665. //  struct ffblk ffblk;
  666. //  scr_rec rec;
  667. //  date today;
  668. //  date lastday;
  669. //  char *temp;
  670.  
  671.  
  672. // don't believe it's needed here no opendoors stuff used
  673. //    strcpy(od_registered_to,"Your Name");
  674. //    od_registration_key=00000000000000L;
  675.  
  676.   randomize();
  677.  
  678. //  od_control.od_disable = DIS_NAME_PROMPT;
  679.  
  680.   directvideo=0;
  681.  
  682. //  strcpy(od_control.od_prog_name,"New York 2008 IBBS MODULE");
  683.  
  684. //  od_control.od_config_function = CustomConfigFunction;
  685.  
  686. //  od_control.od_mps=INCLUDE_MPS;
  687. //  od_control.od_nocopyright=TRUE;
  688. //  od_control.od_help_text2=(char *)"  New York 2008 v0.01 WIDE BETA 3 (c) Copyright 1995 George Lebl               ";
  689. /*  od_control.od_cbefore_chat=ny_chat;
  690. //  od_control.od_cafter_chat=scr_res;
  691.   od_control.od_cbefore_shell=scr_save;
  692.   od_control.od_cafter_shell=scr_res;*/
  693.  
  694.  
  695.   if(findfirst("NY2008.CFG",&fff,0)==0) {
  696. //    printf("&|%s|&",bbs_namei);
  697.     IBReadConfig(&IBBSInfo, "NY2008.CFG");
  698. //    printf("&|%s|&",bbs_namei);
  699.   }
  700.  
  701. //  printf("|%s|",bbs_namei);
  702.  
  703.  
  704.   cnt=1;
  705.   if(argc>1) {
  706.     do {
  707.       if (strnicmp(argv[cnt],"-IBBSI",6)==0) {
  708.     ibbs_maint_i=TRUE;
  709.       } else if (strnicmp(argv[cnt],"-IBBSO",6)==0) {
  710.     ibbs_maint_o=TRUE;
  711.       } else if (strnicmp(argv[cnt],"-SENDNODELIST",13)==0) {
  712.     ibbs_send_nodelist=TRUE;
  713.       } else if (strnicmp(argv[cnt],"-C",2)==0) {
  714.     if(findfirst(&argv[cnt][2],&fff,0)==0)
  715.     IBReadConfig(&IBBSInfo, &argv[cnt][2]);
  716.  
  717. //      strzcpy(od_control.od_config_filename,argv[cnt],2,59);
  718. //      od_control.od_config_file = INCLUDE_CONFIG_FILE;
  719.       }
  720.     } while ((++cnt)<argc);
  721.   }
  722.  
  723. //  od_control.od_force_local=TRUE;
  724. //  od_init();
  725.  
  726. //  if(no_slices==FALSE)
  727. //    od_control.od_ker_exec=time_slice;
  728. //  else
  729. //    od_control.od_ker_exec=NULL;
  730.  
  731. //  if(od_control.user_screen_length<2)
  732. //    od_control.user_screen_length=24;
  733.  
  734. //  od_control.od_help_text2=(char *)"  New York 2008 v0.10 InterBBS Module (c) 1996 George Lebl                    ";
  735.  
  736.   char *InComing;
  737.   char *OutGoing;
  738.   int found=FALSE;
  739.   //ibbs_bbs_rec_type ibbest;
  740.   ibbs_bbs_spy_rec bbs_spy_rec;
  741.   ibbs_mail_type ibmail;
  742.   user_rec urec_i;
  743.   ibbs_bbs_rec bbs_rec;
  744.   ibbs_scr_rec ibscr_rec;
  745.   FILE *jfile;
  746.   ibbs_scr_rec ibscr_rec2;
  747.   best_rec_type best_rec;
  748.   ibbs_act_rec act_rec;
  749.   ibbs_scr_spy_rec scr_spy_rec;
  750.   int pack_spy=FALSE;
  751.   long msgnum;
  752.   int bufferlen;
  753. /*
  754. //  if (findfirst("NYREG.KEY",&fff,0)==0) {
  755.     strcpy(numstr,bbs_namei);
  756. //    printf("|%s|",bbs_namei);
  757.     get_bbsname(numstr);
  758. //    printf("|%s|",numstr);
  759.     if(seereg(numstr)==FALSE) {
  760.       printf("\nUNREGISTERED... InterBBS DISABLED!!\n");
  761.       exit(10);
  762.     }*/
  763. /*  } else {
  764.     printf("\nUNREGISTERED... InterBBS DISABLED!!\n");
  765.     exit(10);
  766.   }*/
  767.  
  768.   if(ibbsi==TRUE) {
  769. //    ch_game_d();
  770.     int xx;
  771.     strcpy(IBBSInfo.szThisNodeAddress, "0:000/000");
  772.     sprintf(IBBSInfo.szProgName, "#@NYG#%05d IBBS",ibbsi_game_num);
  773.     strcpy(IBBSInfo.szNetmailDir, "C:\FD\NETMAIL");
  774.     IBBSInfo.bCrash = FALSE;
  775.     IBBSInfo.bHold = FALSE;
  776.     IBBSInfo.bEraseOnSend = TRUE;
  777.     IBBSInfo.bEraseOnReceive = TRUE;
  778.     IBBSInfo.nTotalSystems = 0;
  779.     IBBSInfo.paOtherSystem = NULL;
  780.     IBReadConfig(&IBBSInfo, "INTERBBS.CFG");
  781.     IBReadConfig(&IBBSInfo, "NYNODE.LST");
  782.  
  783.  
  784.     char szDirFileName[PATH_CHARS + 1];
  785.  
  786.    if(IBBSInfo.szNetmailDir==NULL || strlen(IBBSInfo.szNetmailDir)>PATH_CHARS) {
  787.      printf("\n\nNETMAIL DIR NOT FOUND\n\n");
  788.      exit(10);
  789.    }
  790.  
  791. //   assert(IBBSInfo.szNetmailDir != NULL);
  792. //   assert(strlen(IBBSInfo.szNetmailDir) <= PATH_CHARS);
  793.  
  794.    strcpy(szDirFileName, IBBSInfo.szNetmailDir);
  795.  
  796. //   Remove any trailing backslash from directory name
  797.    if(szDirFileName[strlen(szDirFileName) - 1] == '\\')
  798.      szDirFileName[strlen(szDirFileName) - 1] = '\0';
  799.  
  800.  
  801.    //Return true iff file exists and it is a directory
  802.    if(!(findfirst(szDirFileName, &fff, FA_ARCH|FA_DIREC) == 0 && (fff.ff_attrib & FA_DIREC))) {
  803.      printf("\n\nNETMAIL DIR NOT FOUND\n\n");
  804.      exit(10);
  805.    }
  806.  
  807.     if(IBBSInfo.nTotalSystems>255)
  808.       IBBSInfo.nTotalSystems=255;
  809.  
  810.     if(ibbs_maint_i) {
  811.       printf("\n##> Getting InterBBS Mail\n");
  812.       sprintf(IBBSInfo.szProgName, "#@NYG#%05d MAIL",ibbsi_game_num);
  813.  
  814.       justfile=ShareFileOpen("NYIBBS.MIN","a+b");
  815.       //while(IBGet(&IBBSInfo,&ibmail,sizeof(ibbs_mail_type)) == eSuccess) {
  816. /*      for(x=0;x<(sizeof(ibbs_mail_type));x++)
  817.     *(((char *)&ibmail)+x)=0;*/
  818.       while(IBGetMail(&IBBSInfo,&ibmail) == eSuccess) {
  819. /*      printf(">>>(%s|",ibmail.sender);
  820.     printf("%s|",ibmail.senderI);
  821.     printf("%s|",ibmail.node_s);
  822.     printf("%s|",ibmail.node_r);
  823.     printf("%s|",ibmail.recver);
  824.     printf("%s)<<<\n\n",ibmail.recverI);*/
  825.  
  826.     if(strcmp(ibmail.node_r,IBBSInfo.szThisNodeAddress)==0)
  827.       ny_fwrite(&ibmail,sizeof(ibbs_mail_type),1,justfile);
  828.       }
  829.       fclose(justfile);
  830.     }
  831.  
  832.     if(ibbs_send_nodelist && ibbsi_operator) {
  833. //      od_control.od_status_on=FALSE;
  834. //      od_set_statusline(STATUS_NONE);
  835.       printf("\n##> Sending Node List\n");
  836.       sprintf(IBBSInfo.szProgName, "#@NYG#%05d NODELIST",ibbsi_game_num);
  837.       //if(IBBSInfo.nTotalSystems<=20)
  838.  
  839.       OutGoing=(char *)malloc(sizeof(tOtherNode)*IBBSInfo.nTotalSystems+1);
  840.       *OutGoing=(char)IBBSInfo.nTotalSystems;
  841.       memcpy(OutGoing+1,(char *)IBBSInfo.paOtherSystem,sizeof(tOtherNode)*IBBSInfo.nTotalSystems);
  842.       if(IBSendAll(&IBBSInfo,OutGoing,sizeof(tOtherNode) * IBBSInfo.nTotalSystems+1)!=eSuccess) {
  843.     printf("\n\nINTERBBS ERROR:Can't send the NODELIST!!!\n\n");
  844.     sleep(4);
  845.       }
  846.  
  847.       free(OutGoing);
  848.     }
  849.     if(ibbs_maint_i) {
  850. //      od_control.od_status_on=FALSE;
  851. //      od_set_statusline(STATUS_NONE);
  852.       printf("\n##> Refreshing Local Best List (if there is one)\n");
  853.  
  854.       RefreshBest();
  855.  
  856.       printf("\n##> Processing Incoming Information\n");
  857.  
  858.       if(ibbsi_operator==FALSE) {
  859.     sprintf(IBBSInfo.szProgName, "#@NYG#%05d NODELIST",ibbsi_game_num);
  860.     InComing=(char *)malloc(sizeof(tOtherNode)*258);
  861.     if(InComing==NULL) {
  862.       printf("\n\nINTERBBS ERROR:Not Enough Memory to process!\n");
  863.       sleep(4);
  864.       exit(12);
  865.     }
  866.     while(IBGet(&IBBSInfo,InComing,sizeof(tOtherNode)*258) == eSuccess) {
  867.       IBBSInfo.nTotalSystems=*InComing;
  868.       InComing++;
  869.       free(IBBSInfo.paOtherSystem);
  870.       IBBSInfo.paOtherSystem=(tOtherNode *)malloc(sizeof(tOtherNode)*IBBSInfo.nTotalSystems);
  871.       memcpy((char *)IBBSInfo.paOtherSystem,InComing,sizeof(tOtherNode)*IBBSInfo.nTotalSystems);
  872. //        free(InComing);
  873.       justfile=ShareFileOpenAR("NYNODE.LST","wt");
  874.       fprintf(justfile,";Only the central system operator should change this node list!\n");
  875.       for(x=0;x<IBBSInfo.nTotalSystems;x++) {
  876.         fprintf(justfile,"LinkWith        %s\n",((tOtherNode *)InComing)[x].szAddress);
  877.         fprintf(justfile,"LinkName        %s\n",((tOtherNode *)InComing)[x].szSystemName);
  878.         fprintf(justfile,"LinkLocation    %s\n\n",((tOtherNode *)InComing)[x].szLocation);
  879.       }
  880.       fclose(justfile);
  881.       InComing--;
  882.     }
  883.     free(InComing);
  884.       }
  885. //      od_printf("1");
  886. //      od_get_answer("1");
  887.  
  888.       sprintf(IBBSInfo.szProgName, "#@NYG#%05d LISTREQ",ibbsi_game_num);
  889.  
  890.       InComing=(char *)malloc(NODE_ADDRESS_CHARS + 1);
  891.  
  892.       while(IBGet(&IBBSInfo,InComing,NODE_ADDRESS_CHARS + 1) == eSuccess) {
  893.        if(strcmp(InComing,IBBSInfo.szThisNodeAddress)!=0) {
  894.     sprintf(IBBSInfo.szProgName, "#@NYG#%05d NAMELIST",ibbsi_game_num);
  895.     justfile=ShareFileOpen(USER_FILENAME,"rb");
  896.     cnt=filelength(fileno(justfile))/sizeof(user_rec);
  897.     OutGoing=(char *)malloc(((25+36+1)*cnt)+NODE_ADDRESS_CHARS + 4);
  898.     OutGoing+=2;
  899.     x=0;
  900.     while(ny_fread(&urec_i,sizeof(user_rec),1,justfile)==1) {
  901.       strcpy(OutGoing+1+((25+36+1)*x),urec_i.name);
  902.       strcpy(OutGoing+1+((25+36+1)*x)+25,urec_i.bbsname);
  903.       *(OutGoing+(25+36+1)*(x+1))=(char)urec_i.sex;
  904.       x++;
  905.     }
  906.     strcpy(OutGoing+1+((25+36+1)*cnt),IBBSInfo.szThisNodeAddress);
  907.     if(x>0) {
  908.       *OutGoing=cnt;
  909.       OutGoing-=2;
  910.       *(int *)OutGoing=((25+36+1)*cnt)+NODE_ADDRESS_CHARS + 2;
  911.       IBSend(&IBBSInfo,InComing,OutGoing,((25+36+1)*cnt)+NODE_ADDRESS_CHARS + 4);
  912.     } else {
  913.       OutGoing-=2;
  914.     }
  915.     fclose(justfile);
  916.     free(OutGoing);
  917.     sprintf(IBBSInfo.szProgName, "#@NYG#%05d LISTREQ",ibbsi_game_num);
  918.        }
  919.       }
  920.       free(InComing);
  921. //      free(OutGoing);
  922.  
  923. //      od_printf("2");
  924. //      od_get_answer("1");
  925.  
  926.       sprintf(IBBSInfo.szProgName, "#@NYG#%05d NEWS",ibbsi_game_num);
  927.  
  928.       struct {
  929.     char  tagline[80],
  930.           name[25],
  931.           name2[36];
  932.     int   flag;
  933.       } newzfile;
  934.  
  935.  
  936.       while(IBGet(&IBBSInfo,(char *)&newzfile,sizeof(newzfile)) == eSuccess) {
  937. //      ch_game_d();
  938.     justfile=ShareFileOpen("NYNEWS.TOD","a+b");
  939.     ny_fwrite(&newzfile,sizeof(newzfile),1,justfile);
  940.     fclose(justfile);
  941.       }
  942.  
  943.       sprintf(IBBSInfo.szProgName, "#@NYG#%05d BBSINFO",ibbsi_game_num);
  944.  
  945. //      od_printf("1");
  946. //      od_get_answer("1");
  947.       while(IBGet(&IBBSInfo,(char *)&bbs_rec,sizeof(bbs_rec)) == eSuccess) {
  948. //      od_printf("2");
  949. //      od_get_answer("1");
  950.     justfile=ShareFileOpen("NYIBBS.SPY","r+b");
  951.     //fseek(justfile,0,SEEK_SET);
  952.     if(justfile==NULL) {
  953.       justfile=ShareFileOpen("NYIBBS.SPY","wb");
  954.       bbs_spy_rec.player_list=0;
  955.       bbs_spy_rec.players=0;
  956.       strcpy(bbs_spy_rec.node,bbs_rec.node);
  957.       bbs_spy_rec.hi_points=bbs_rec.hi_points;
  958.       ny_fwrite(&bbs_spy_rec,sizeof(ibbs_bbs_spy_rec),1,justfile);
  959.       fclose(justfile);
  960.     } else {
  961.       xx=0;
  962.       found=FALSE;
  963.       while(ny_fread(&bbs_spy_rec,sizeof(ibbs_bbs_spy_rec),1,justfile)==1) {
  964.         if(strcmp(bbs_rec.node,bbs_spy_rec.node)==0) {
  965.           bbs_spy_rec.hi_points=bbs_rec.hi_points;
  966.           fseek(justfile,(long)xx * sizeof(ibbs_bbs_spy_rec),SEEK_SET);
  967.           ny_fwrite(&bbs_spy_rec,sizeof(ibbs_bbs_spy_rec),1,justfile);
  968.           found=TRUE;
  969.           break;
  970.         }
  971.         xx++;
  972.         fseek(justfile,(long)xx * sizeof(ibbs_bbs_spy_rec),SEEK_SET);
  973.       }
  974.       fclose(justfile);
  975. //        od_printf("3");
  976. //        od_get_answer("1");
  977.       if(found==FALSE) {
  978.         justfile=ShareFileOpen("NYIBBS.SPY","ab");
  979.         bbs_spy_rec.player_list=0;
  980.         bbs_spy_rec.players=0;
  981.         strcpy(bbs_spy_rec.node,bbs_rec.node);
  982.         bbs_spy_rec.hi_points=bbs_rec.hi_points;
  983.         ny_fwrite(&bbs_spy_rec,sizeof(ibbs_bbs_spy_rec),1,justfile);
  984.         fclose(justfile);
  985.       }
  986.     }
  987.       }
  988. //      od_printf("4");
  989. //      od_get_answer("1");
  990.  
  991.       sprintf(IBBSInfo.szProgName, "#@NYG#%05d NAMELIST",ibbsi_game_num);
  992.  
  993.       //InComing=(char *)malloc(((25+36+1)*10)+NODE_ADDRESS_CHARS + 2);
  994.  
  995.       while(IBGetLen(&IBBSInfo,&msgnum,&bufferlen) == eSuccess) {
  996.     InComing=(char *)malloc(bufferlen);
  997.     IBGetR(&IBBSInfo,InComing,bufferlen,msgnum);
  998.  
  999.     cnt=*InComing;
  1000.  
  1001. //      printf("\nPlayers in the list: |%d|\n",cnt);
  1002. //      od_get_answer("1");
  1003.     justfile=ShareFileOpen("NYIBBS.SPY","r+b");
  1004.     //fseek(justfile,0,SEEK_SET);
  1005. //      printf("3");
  1006.     xx=0;
  1007. //      printf("4");
  1008.  
  1009. //      printf("\n*|N#%s|\n",InComing+1);//+((25+36+1)*cnt));
  1010. //      printf("*|N#%s|\n",InComing+26);//+((25+36+1)*(cnt-1)));
  1011. //      od_get_answer("1");
  1012.  
  1013.     while(ny_fread(&bbs_spy_rec,sizeof(ibbs_bbs_spy_rec),1,justfile)==1) {
  1014. //        printf("5");
  1015.       if(strcmp(InComing+1+((25+36+1)*cnt),bbs_spy_rec.node)==0) {
  1016. //          printf("6");
  1017.         if(bbs_spy_rec.player_list!=0) {
  1018. //            printf("7");
  1019.           sprintf(numstr,"NYSPYDBT.%03d",bbs_spy_rec.player_list);
  1020.           njustfile=ShareFileOpen(numstr,"wb");
  1021.           for(x=0;x < cnt;x++) {
  1022.         strcpy(ibscr_rec.name,InComing+1+((25+36+1)*x));
  1023.         strcpy(ibscr_rec.nameI,InComing+1+((25+36+1)*x)+25);
  1024.         ibscr_rec.sex=*(sex_type *)(InComing+(25+36+1)*(x+1));
  1025. //              printf("\n+|%s|%s|%d|\n",ibscr_rec.name,ibscr_rec.nameI,(int)ibscr_rec.sex);
  1026. //              od_get_answer("1");
  1027.  
  1028.         ibscr_rec.level=-1;
  1029.         ny_fwrite(&ibscr_rec,sizeof(ibbs_scr_rec),1,njustfile);
  1030.           }
  1031. //            printf("8");
  1032.           fclose(njustfile);
  1033. //            printf("9");
  1034.         } else {
  1035.           bbs_spy_rec.player_list=0;
  1036.           do {
  1037.         bbs_spy_rec.player_list++;
  1038.         sprintf(numstr,"NYSPYDB.%03d",bbs_spy_rec.player_list);
  1039.           } while(findfirst(numstr,&fff,0)==0);
  1040.           njustfile=ShareFileOpen(numstr,"wb");
  1041.           fclose(njustfile);
  1042.           sprintf(numstr,"NYSPYDBT.%03d",bbs_spy_rec.player_list);
  1043.           njustfile=ShareFileOpen(numstr,"wb");
  1044.           for(x=0;x < *InComing;x++) {
  1045.         strcpy(ibscr_rec.name,InComing+1+((25+36+1)*x));
  1046.         strcpy(ibscr_rec.nameI,InComing+1+((25+36+1)*x)+25);
  1047.         ibscr_rec.level=-1;
  1048.         ibscr_rec.sex=*(sex_type *)(InComing+(25+36+1)*(x+1));
  1049. //              od_printf("++|%s|%s|%d|",ibscr_rec.name,ibscr_rec.nameI,(int)ibscr_rec.sex);
  1050. //              od_get_answer("1");
  1051.  
  1052.         ny_fwrite(&ibscr_rec,sizeof(ibbs_scr_rec),1,njustfile);
  1053.           }
  1054. //            printf("A");
  1055.           fclose(njustfile);
  1056. //            printf("B");
  1057.           fseek(justfile,(long)xx * sizeof(ibbs_bbs_spy_rec),SEEK_SET);
  1058. //            printf("C");
  1059.           ny_fwrite(&bbs_spy_rec,sizeof(ibbs_bbs_spy_rec),1,justfile);
  1060.         }
  1061.         break;
  1062.       }
  1063.       xx++;
  1064.       fseek(justfile,(long)xx * sizeof(ibbs_bbs_spy_rec),SEEK_SET);
  1065. //        printf("D");
  1066.     }
  1067.     fclose(justfile);
  1068. //      printf("E");
  1069.     free(InComing);
  1070. //      printf("\nKKK\n");
  1071. //      printf("F");
  1072.       }
  1073. //      free(InComing);
  1074. //      printf("G");
  1075.  
  1076.  
  1077. //      od_printf("6");
  1078. //      od_get_answer("1");
  1079. //      printf("H");
  1080.  
  1081.       while(findfirst("NYSPYDBT.*",&ff,0)==0) {
  1082. //      printf("I");
  1083.  
  1084.     sscanf(ff.ff_name,"NYSPYDBT.%d",&cnt);
  1085.     sprintf(numstr,"NYSPYDB.%03d",cnt);
  1086.     copyfile(numstr,"NYSPYDB.TMP");
  1087.     ny_remove(numstr);
  1088.  
  1089. //      printf("J");
  1090.     jfile=ShareFileOpen(ff.ff_name,"rb");
  1091. //      printf("K");
  1092.  
  1093.     while(ny_fread(&ibscr_rec,sizeof(ibbs_scr_rec),1,jfile)==1) {
  1094. //        printf("L");
  1095.  
  1096.       njustfile=ShareFileOpen("NYSPYDB.TMP","r+b");
  1097.       justfile=ShareFileOpen(numstr,"a+b");
  1098.       found=FALSE;
  1099. //        printf("M");
  1100.       x=0;
  1101.  
  1102.       while(ny_fread(&ibscr_rec2,sizeof(ibbs_scr_rec),1,njustfile)==1) {
  1103.  
  1104. //          printf("N");
  1105.         if(strcmp(ibscr_rec.nameI,ibscr_rec2.nameI)==0) {
  1106.           if(ibscr_rec2.level!= -66) {
  1107.         strcpy(ibscr_rec2.name,ibscr_rec.name);
  1108.         ibscr_rec2.sex=ibscr_rec.sex;
  1109.         ny_fwrite(&ibscr_rec,sizeof(ibbs_scr_rec),1,justfile);
  1110.         fseek(njustfile,(long)x * sizeof(ibbs_scr_rec),SEEK_SET);
  1111.         ibscr_rec2.level= -66;
  1112.         ny_fwrite(&ibscr_rec2,sizeof(ibbs_scr_rec),1,njustfile);
  1113.           }
  1114.           found=TRUE;
  1115.           break;
  1116.         }
  1117. //          printf("O");
  1118.         x++;
  1119.         fseek(njustfile,(long)x * sizeof(ibbs_scr_rec),SEEK_SET);
  1120.       }
  1121. //        printf("P");
  1122.       if(found==FALSE)
  1123.         ny_fwrite(&ibscr_rec,sizeof(ibbs_scr_rec),1,justfile);
  1124.       fclose(njustfile);
  1125.       fclose(justfile);
  1126.  
  1127. //        printf("Q");
  1128.  
  1129.     }
  1130. //      printf("R");
  1131.     fclose(jfile);
  1132.  
  1133.     ny_remove(ff.ff_name);
  1134.     ny_remove("NYSPYDB.TMP");
  1135. //      printf("S");
  1136.     justfile=ShareFileOpen("NYIBBS.SPY","r+b");
  1137.     //fseek(justfile,0,SEEK_SET);
  1138.     xx=0;
  1139.     while(ny_fread(&bbs_spy_rec,sizeof(ibbs_bbs_spy_rec),1,justfile)==1) {
  1140.       if(bbs_spy_rec.player_list==cnt && cnt!=0) {
  1141.         sprintf(numstr,"NYSPYDB.%03d",bbs_spy_rec.player_list);
  1142.         njustfile=ShareFileOpen(numstr,"rb");
  1143.         bbs_spy_rec.players=filelength(fileno(njustfile))/sizeof(ibbs_scr_rec);
  1144.         fclose(njustfile);
  1145.  
  1146.         fseek(justfile,(long)xx * sizeof(ibbs_bbs_spy_rec),SEEK_SET);
  1147.         ny_fwrite(&bbs_spy_rec,sizeof(ibbs_bbs_spy_rec),1,justfile);
  1148.         break;
  1149.       }
  1150.       xx++;
  1151.       fseek(justfile,(long)xx * sizeof(ibbs_bbs_spy_rec),SEEK_SET);
  1152.     }
  1153.     fclose(justfile);
  1154. //      printf("T");
  1155.       }
  1156. //      printf("U");
  1157.  
  1158. //      od_printf("7");
  1159. //      od_get_answer("1");
  1160.  
  1161.       sprintf(IBBSInfo.szProgName, "#@NYG#%05d TENBEST",ibbsi_game_num);
  1162.       //free(InComing);
  1163.       InComing=(char *)malloc(NODE_ADDRESS_CHARS + 2 + (10 * sizeof(bbs_rec)));
  1164.       while(IBGet(&IBBSInfo,InComing,NODE_ADDRESS_CHARS + 2 + (10 * sizeof(bbs_rec))) == eSuccess) {
  1165.     x= *InComing;
  1166. //      OutGoing++;
  1167. //      strcpy(OutGoing,IBBSInfo.szThisNodeAddress);
  1168. //      od_printf("A");
  1169. //      od_get_answer("1");
  1170.  
  1171.  
  1172.  
  1173.     InComing+=NODE_ADDRESS_CHARS+2;
  1174.     for(cnt=0;cnt<x;cnt++) {
  1175. //        od_printf("B");
  1176. //        od_get_answer("1");
  1177. //        printf("???%s???%ld???\n",((best_rec_type *)(InComing+(cnt*sizeof(best_rec))))->name,((best_rec_type *)(InComing+(cnt*sizeof(best_rec))))->points);
  1178.       AddBestPlayerInIB(((best_rec_type *)(InComing+(cnt*sizeof(best_rec))))->name,((best_rec_type *)(InComing+(cnt*sizeof(best_rec))))->points,InComing-NODE_ADDRESS_CHARS-1);
  1179.     }
  1180. //      od_printf("C");
  1181. //      od_get_answer("1");
  1182.  
  1183.     InComing-=NODE_ADDRESS_CHARS+2;
  1184.       }
  1185.       free(InComing);
  1186.  
  1187.       sprintf(IBBSInfo.szProgName, "#@NYG#%05d ACTIONS",ibbsi_game_num);
  1188.  
  1189. //      od_printf("8");
  1190. //      od_get_answer("1");
  1191.  
  1192.       while(IBGet(&IBBSInfo,(char *)&act_rec,sizeof(ibbs_act_rec)) == eSuccess) {
  1193.     if(act_rec.action==0) {
  1194.       justfile=ShareFileOpen("NYIBBS.SPY","rb");
  1195.       if(justfile!=NULL) {
  1196.         while(ny_fread(&bbs_spy_rec,sizeof(ibbs_bbs_spy_rec),1,justfile)==1) {
  1197.           if(strcmp(bbs_spy_rec.node,act_rec.node_s)==0) {
  1198.         if(bbs_spy_rec.player_list==0) {
  1199.           if(strcmp(act_rec.node_s,IBBSInfo.szThisNodeAddress)!=0) {
  1200.             sprintf(IBBSInfo.szProgName, "#@NYG#%05d LISTREQ",ibbsi_game_num);
  1201.             IBSend(&IBBSInfo,act_rec.node_s,IBBSInfo.szThisNodeAddress,NODE_ADDRESS_CHARS + 1);
  1202.             sprintf(IBBSInfo.szProgName, "#@NYG#%05d ACTIONS",ibbsi_game_num);
  1203.           }
  1204.           break;
  1205.         } else {
  1206.           sprintf(numstr,"NYSPYDB.%03d",bbs_spy_rec.player_list);
  1207.           fclose(justfile);
  1208.           justfile=ShareFileOpen(numstr,"r+b");
  1209.           x=0;
  1210.           while(ny_fread(&ibscr_rec,sizeof(ibbs_scr_rec),1,justfile)==1) {
  1211.             if(strcmp(ibscr_rec.nameI,act_rec.name_sI)==0) {
  1212.               strcpy(ibscr_rec.name,act_rec.name_s);
  1213.               fseek(justfile,(long)x * sizeof(ibbs_scr_rec),SEEK_SET);
  1214.               ny_fwrite(&ibscr_rec,sizeof(ibbs_scr_rec),1,justfile);
  1215.               break;
  1216.             }
  1217.             x++;
  1218.             fseek(justfile,(long)x * sizeof(ibbs_scr_rec),SEEK_SET);
  1219.           }
  1220.           break;
  1221.  
  1222.         }
  1223.           }
  1224.         }
  1225.         fclose(justfile);
  1226.       } else {
  1227.         if(strcmp(act_rec.node_s,IBBSInfo.szThisNodeAddress)!=0) {
  1228.           sprintf(IBBSInfo.szProgName, "#@NYG#%05d LISTREQ",ibbsi_game_num);
  1229.           IBSend(&IBBSInfo,act_rec.node_s,IBBSInfo.szThisNodeAddress,NODE_ADDRESS_CHARS + 1);
  1230.           sprintf(IBBSInfo.szProgName, "#@NYG#%05d ACTIONS",ibbsi_game_num);
  1231.         }
  1232.       }
  1233.     } else if(act_rec.action==1) {
  1234.       justfile=ShareFileOpen(USER_FILENAME,"rb");
  1235.       scr_spy_rec.nameI[0]=0;
  1236.       while(ny_fread(&urec_i,sizeof(user_rec),1,justfile)==1) {
  1237.         if(strcmp(urec_i.bbsname,act_rec.name_rI)==0) {
  1238.           strcpy(scr_spy_rec.name,urec_i.name);
  1239.           strcpy(scr_spy_rec.nameI,urec_i.bbsname);
  1240.           scr_spy_rec.nation=urec_i.nation;
  1241.           scr_spy_rec.level=urec_i.level;
  1242.           scr_spy_rec.points=urec_i.points;
  1243.           scr_spy_rec.sex=urec_i.sex;
  1244.           strcpy(scr_spy_rec.node,IBBSInfo.szThisNodeAddress);
  1245.           break;
  1246.         }
  1247.       }
  1248.       fclose(justfile);
  1249.       if(scr_spy_rec.nameI[0]!=0) {
  1250.         sprintf(IBBSInfo.szProgName, "#@NYG#%05d SPYINFO",ibbsi_game_num);
  1251.         IBSend(&IBBSInfo,act_rec.node_s,(char *)&scr_spy_rec,sizeof(ibbs_scr_spy_rec));
  1252.         sprintf(IBBSInfo.szProgName, "#@NYG#%05d ACTIONS",ibbsi_game_num);
  1253.       }
  1254.     }
  1255.       }
  1256.  
  1257. //      od_printf("9");
  1258. //      od_get_answer("1");
  1259.  
  1260.       sprintf(IBBSInfo.szProgName, "#@NYG#%05d SPYINFO",ibbsi_game_num);
  1261.       while(IBGet(&IBBSInfo,(char *)&scr_spy_rec,sizeof(ibbs_scr_spy_rec)) == eSuccess) {
  1262. //      od_printf("*");
  1263. //      od_get_answer("1");
  1264.  
  1265.     justfile=ShareFileOpen("NYIBBS.SPY","rb");
  1266.     if(justfile!=NULL) {
  1267.       while(ny_fread(&bbs_spy_rec,sizeof(ibbs_bbs_spy_rec),1,justfile)==1) {
  1268.         if(strcmp(bbs_spy_rec.node,scr_spy_rec.node)==0 && bbs_spy_rec.player_list!=0) {
  1269.           sprintf(numstr,"NYSPYDB.%03d",bbs_spy_rec.player_list);
  1270.           fclose(justfile);
  1271.           justfile=ShareFileOpen(numstr,"r+b");
  1272.           x=0;
  1273.           while(ny_fread(&ibscr_rec,sizeof(ibbs_scr_rec),1,justfile)==1) {
  1274.         if(strcmp(ibscr_rec.nameI,scr_spy_rec.nameI)==0) {
  1275.           strcpy(ibscr_rec.name,scr_spy_rec.name);
  1276.           ibscr_rec.nation=scr_spy_rec.nation;
  1277.           ibscr_rec.level=scr_spy_rec.level;
  1278.           ibscr_rec.points=scr_spy_rec.points;
  1279.           ibscr_rec.sex=scr_spy_rec.sex;
  1280.           fseek(justfile,(long)x * sizeof(ibbs_scr_rec),SEEK_SET);
  1281.           ny_fwrite(&ibscr_rec,sizeof(ibbs_scr_rec),1,justfile);
  1282.           break;
  1283.         }
  1284.         x++;
  1285.         fseek(justfile,(long)x * sizeof(ibbs_scr_rec),SEEK_SET);
  1286.           }
  1287.           break;
  1288.         }
  1289.       }
  1290.       fclose(justfile);
  1291.     }
  1292.       }
  1293. //      printf("~~~");
  1294. //      od_printf("10");
  1295. //      od_get_answer("1");
  1296.     }
  1297.     if(ibbs_maint_o) {
  1298. //      od_control.od_status_on=FALSE;
  1299. //      od_set_statusline(STATUS_NONE);
  1300.       printf("\n##> Processing Outgoing Information\n");
  1301.  
  1302.       sprintf(IBBSInfo.szProgName, "#@NYG#%05d BBSINFO",ibbsi_game_num);
  1303.       strcpy(bbs_rec.node,IBBSInfo.szThisNodeAddress);
  1304.  
  1305.       justfile=ShareFileOpen(USER_FILENAME,"rb");
  1306.       bbs_rec.hi_points=0;
  1307.       cnt=0;
  1308.       while(ny_fread(&urec_i,sizeof(user_rec),1,justfile)==1) {
  1309.     if(urec_i.points>bbs_rec.hi_points)
  1310.       bbs_rec.hi_points=urec_i.points;
  1311.       }
  1312.       fclose(justfile);
  1313.  
  1314.       if(IBSendAll(&IBBSInfo,(char *)&bbs_rec,sizeof(ibbs_bbs_rec))!=eSuccess) {
  1315.     printf("\n\nINTERBBS ERROR:Can't send the BBSINFO!!!\n\n");
  1316.     sleep(4);
  1317.       }
  1318.  
  1319.       if(findfirst("SENTLIST.PL",&fff,0)!=0) {
  1320.     //OutGoing=(char *)malloc(((25+36)*10)+NODE_ADDRESS_CHARS + 2);
  1321.  
  1322.     sprintf(IBBSInfo.szProgName, "#@NYG#%05d NAMELIST",ibbsi_game_num);
  1323.     justfile=ShareFileOpen(USER_FILENAME,"rb");
  1324.     cnt=filelength(fileno(justfile))/sizeof(user_rec);
  1325. //      printf("\n& Len of file: %ld  len of user_rec : %ld",(long)filelength(fileno(justfile)),(long)sizeof(user_rec));
  1326.     OutGoing=(char *)malloc(((25+36+1)*cnt)+NODE_ADDRESS_CHARS + 4);
  1327.     OutGoing+=2;
  1328.     x=0;
  1329. //      strcpy(OutGoing+1+((25+36+1)*cnt),IBBSInfo.szThisNodeAddress);
  1330.     while(ny_fread(&urec_i,sizeof(user_rec),1,justfile)==1) {
  1331.       strcpy((OutGoing+1+((25+36+1)*x)),urec_i.name);
  1332. //        printf("\n[%d] - {%s} - |%s|",x,(OutGoing+1+((25+36+1)*x)),urec_i.name);
  1333.       strcpy(OutGoing+1+((25+36+1)*x)+25,urec_i.bbsname);
  1334. //        printf("\n[%d] - {%s} - |%s|",x,(OutGoing+1+((25+36+1)*x)+25),urec_i.bbsname);
  1335.       *(OutGoing+(25+36+1)*(x+1))=(char)urec_i.sex;
  1336. //        printf("\n[%d] - {%s} - |%s|",x,(OutGoing+1+((25+36+1)*x)),urec_i.name);
  1337.       x++;
  1338.     }
  1339.     strcpy(OutGoing+1+((25+36+1)*cnt),IBBSInfo.szThisNodeAddress);
  1340.     if(x>0) {
  1341.       *OutGoing=cnt;
  1342. //        printf("\nPlayers on the list: {%d}\n",cnt);
  1343.       OutGoing-=2;
  1344.       *(int *)OutGoing=((25+36+1)*cnt)+NODE_ADDRESS_CHARS + 2;
  1345.       IBSendAll(&IBBSInfo,OutGoing,((25+36+1)*cnt)+NODE_ADDRESS_CHARS + 4);
  1346.     } else {
  1347.       OutGoing-=2;
  1348.     }
  1349.     fclose(justfile);
  1350.     free(OutGoing);
  1351.     justfile=ShareFileOpen("SENTLIST.PL","wb");
  1352.     fclose(justfile);
  1353.       }
  1354.  
  1355.       if(findfirst("SENTBEST.TEN",&fff,0)!=0) {
  1356.     justfile=ShareFileOpen("NYBEST.TEN","rb");
  1357.     if(justfile!=NULL) {
  1358. //        best_rec_type best_rec;
  1359.  
  1360.       sprintf(IBBSInfo.szProgName, "#@NYG#%05d TENBEST",ibbsi_game_num);
  1361.       OutGoing=(char *)malloc(NODE_ADDRESS_CHARS + 2 + (10 * sizeof(best_rec)));
  1362.       OutGoing++;
  1363.       strcpy(OutGoing,IBBSInfo.szThisNodeAddress);
  1364.       OutGoing+=NODE_ADDRESS_CHARS+1;
  1365.       x=0;
  1366.       while(ny_fread(&best_rec,sizeof(best_rec),1,justfile)==1) {
  1367.         memcpy((OutGoing+(x*sizeof(best_rec))),&best_rec,sizeof(best_rec));
  1368.         x++;
  1369.       }
  1370.       fclose(justfile);
  1371.       OutGoing-=NODE_ADDRESS_CHARS+2;
  1372.       *OutGoing=(char)x;
  1373.       if(IBSendAll(&IBBSInfo,OutGoing,NODE_ADDRESS_CHARS + 2 + (10 * sizeof(best_rec)))!=eSuccess) {
  1374.         printf("\n\nINTERBBS ERROR:Can't send the TEN BEST LIST!!!\n\n");
  1375.         sleep(4);
  1376.       }
  1377.       free(OutGoing);
  1378.       justfile=ShareFileOpen("SENTBEST.TEN","wb");
  1379.       fclose(justfile);
  1380.     }
  1381.       }
  1382.       sprintf(IBBSInfo.szProgName, "#@NYG#%05d LISTREQ",ibbsi_game_num);
  1383.  
  1384.       if(findfirst("NYIBBS.SPY",&fff,0)!=0) {
  1385.     IBSendAll(&IBBSInfo,IBBSInfo.szThisNodeAddress,NODE_ADDRESS_CHARS + 1);
  1386.     justfile=ShareFileOpen("NYIBBS.SPY","wb");
  1387.     for(x=0;x<IBBSInfo.nTotalSystems;x++) {
  1388.       if(strcmp(IBBSInfo.paOtherSystem[x].szAddress,IBBSInfo.szThisNodeAddress)!=0) {
  1389.         strcpy(bbs_spy_rec.node,IBBSInfo.paOtherSystem[x].szAddress);
  1390.         bbs_spy_rec.hi_points=0;
  1391.         bbs_spy_rec.players=0;
  1392.         bbs_spy_rec.player_list=0;
  1393.         ny_fwrite(&bbs_spy_rec,sizeof(ibbs_bbs_spy_rec),1,justfile);
  1394.       }
  1395.     }
  1396.     fclose(justfile);
  1397.       } else {
  1398.     justfile=ShareFileOpen("NYIBBS.SPY","r+b");
  1399.     //fseek(justfile,0,SEEK_SET);
  1400.  
  1401.     pack_spy=FALSE;
  1402.     xx=0;
  1403.     while(ny_fread(&bbs_spy_rec,sizeof(ibbs_bbs_spy_rec),1,justfile)==1) {
  1404.       found=FALSE;
  1405.       for(x=0;x<IBBSInfo.nTotalSystems;x++) {
  1406.         if(strcmp(IBBSInfo.paOtherSystem[x].szAddress,bbs_spy_rec.node)==0) {
  1407.           found=TRUE;
  1408.           break;
  1409.         }
  1410.       }
  1411.       if(found==FALSE) {
  1412.         bbs_spy_rec.node[0]=0;
  1413.         fseek(justfile,(long)xx * sizeof(ibbs_bbs_spy_rec),SEEK_SET);
  1414.         ny_fwrite(&bbs_spy_rec,sizeof(ibbs_bbs_spy_rec),1,justfile);
  1415.  
  1416.         pack_spy=TRUE;
  1417.       }
  1418.       xx++;
  1419.       fseek(justfile,(long)xx * sizeof(ibbs_bbs_spy_rec),SEEK_SET);
  1420.     }
  1421.     fclose(justfile);
  1422.  
  1423.     if(pack_spy==TRUE) {
  1424.       copyfile("NYIBBS.SPY","NYIBBS.TMP");
  1425.       justfile=ShareFileOpen("NYIBBS.TMP","rb");
  1426.       njustfile=ShareFileOpen("NYIBBS.SPY","wb");
  1427.       while(ny_fread(&bbs_spy_rec,sizeof(ibbs_bbs_spy_rec),1,justfile)==1) {
  1428.         if(bbs_spy_rec.node[0]!=0) {
  1429.           ny_fwrite(&bbs_spy_rec,sizeof(ibbs_bbs_spy_rec),1,njustfile);
  1430.         } else if(bbs_spy_rec.player_list!=0) {
  1431.           sprintf(numstr,"NYSPYDB.%03d",bbs_spy_rec.player_list);
  1432.           ny_remove(numstr);
  1433.         }
  1434.       }
  1435.       fclose(justfile);
  1436.       fclose(njustfile);
  1437.       ny_remove("NYIBBS.TMP");
  1438.     }
  1439.  
  1440.     for(x=0;x<IBBSInfo.nTotalSystems;x++) {
  1441.       found=FALSE;
  1442.       justfile=ShareFileOpen("NYIBBS.SPY","rb");
  1443.       while(ny_fread(&bbs_spy_rec,sizeof(ibbs_bbs_spy_rec),1,justfile)==1) {
  1444.         if(strcmp(bbs_spy_rec.node,IBBSInfo.paOtherSystem[x].szAddress)==0) {
  1445.           found=TRUE;
  1446.           if(bbs_spy_rec.player_list==0 && strcmp(bbs_spy_rec.node,IBBSInfo.szThisNodeAddress)!=0)
  1447.         IBSend(&IBBSInfo,bbs_spy_rec.node,IBBSInfo.szThisNodeAddress,NODE_ADDRESS_CHARS + 1);
  1448.           break;
  1449.         }
  1450.       }
  1451.       fclose(justfile);
  1452.       if(found==FALSE) {
  1453.         justfile=ShareFileOpen("NYIBBS.SPY","a+b");
  1454.         strcpy(bbs_spy_rec.node,IBBSInfo.paOtherSystem[x].szAddress);
  1455.         bbs_spy_rec.hi_points=0;
  1456.         bbs_spy_rec.players=0;
  1457.         bbs_spy_rec.player_list=0;
  1458.         ny_fwrite(&bbs_spy_rec,sizeof(ibbs_bbs_spy_rec),1,justfile);
  1459.         fclose(justfile);
  1460.         if(strcmp(bbs_spy_rec.node,IBBSInfo.szThisNodeAddress)!=0)
  1461.           IBSend(&IBBSInfo,bbs_spy_rec.node,IBBSInfo.szThisNodeAddress,NODE_ADDRESS_CHARS + 1);
  1462.       }
  1463.     }
  1464.       }
  1465.       copyfile("NYIBBS.SPY","NYIBBS.TMP");
  1466.       justfile=ShareFileOpen("NYIBBS.TMP","rb");
  1467.       njustfile=ShareFileOpen("NYIBBS.SPY","wb");
  1468.       while(ny_fread(&bbs_spy_rec,sizeof(ibbs_bbs_spy_rec),1,justfile)==1) {
  1469.     for(x=0;x<IBBSInfo.nTotalSystems;x++) {
  1470.       if(strcmp(bbs_spy_rec.node,IBBSInfo.paOtherSystem[x].szAddress)==0) {
  1471.         ny_fwrite(&bbs_spy_rec,sizeof(ibbs_bbs_spy_rec),1,njustfile);
  1472.         break;
  1473.       }
  1474.     }
  1475.       }
  1476.       fclose(njustfile);
  1477.       fclose(justfile);
  1478.       ny_remove("NYIBBS.TMP");
  1479.     }
  1480.   }
  1481. //  printf("&&&");
  1482.   exit(10);
  1483. //  printf("***");
  1484.   return(0);
  1485. }
  1486.  
  1487.  
  1488. size_t
  1489. ny_fwrite(const void *ptr, size_t size, size_t n, FILE *stream)
  1490. {
  1491.   size_t status;
  1492.   long offset;
  1493.   offset=ftell(stream);
  1494.  
  1495.   if(single_node==FALSE && filelength(fileno(stream))>=offset+(size*n)) {
  1496.     //offset=ftell(stream);
  1497.  
  1498.     lock(fileno(stream),offset,size * n);
  1499.     status=fwrite(ptr,size,n,stream);
  1500.     unlock(fileno(stream),offset,size * n);
  1501.   } else {
  1502.     status=fwrite(ptr,size,n,stream);
  1503.   }
  1504. //  if(no_slices==FALSE)
  1505. //    time_slice();
  1506.   return(status);
  1507. }
  1508.  
  1509.  
  1510. size_t
  1511. ny_fread(const void *ptr, size_t size, size_t n, FILE *stream)
  1512. {
  1513.   size_t status;
  1514.   long offset;
  1515.   offset=ftell(stream);
  1516.  
  1517.   if(single_node==FALSE && filelength(fileno(stream))>=offset+(size*n)) {
  1518.     offset=ftell(stream);
  1519.  
  1520.     lock(fileno(stream),offset,size * n);
  1521.     status=fread(ptr,size,n,stream);
  1522.     unlock(fileno(stream),offset,size * n);
  1523.   } else {
  1524.     status=fread(ptr,size,n,stream);
  1525.   }
  1526. //  if(no_slices==FALSE)
  1527. //    time_slice();
  1528.   return(status);
  1529. }
  1530.  
  1531. FILE *ShareFileOpen(char *pszFileName, char *pszMode)
  1532. {
  1533.    FILE *fpFile = NULL;
  1534.    time_t StartTime = time(NULL);
  1535. //   char numstr[14];
  1536. //   ffblk ffblk;
  1537. //   ny_kernel();
  1538.  
  1539.  
  1540.    /* Attempt to open the file while there is still time remaining. */
  1541.    if(single_node==FALSE) {
  1542. /*     if(no_kernel==FALSE) {
  1543.        ny_kernel();
  1544.        sprintf(numstr,"u%07d.rnk",nCurrentUserNumber);
  1545.        if (findfirst(numstr,&fff,0)==0) {
  1546.      no_kernel=TRUE;
  1547.      fpFile=ShareFileOpen(numstr,"rb");
  1548.      ny_fread(&cur_user.rank,2,1,fpFile);
  1549.      no_kernel=FALSE;
  1550.      fclose(fpFile);
  1551.      ny_remove(numstr);
  1552.      wrt_sts();
  1553.        }
  1554.      }*/
  1555.  
  1556.      while((fpFile = _fsopen(pszFileName, pszMode,SH_DENYNO)) == NULL
  1557.     && errno == EACCES
  1558.     && difftime(time(NULL), StartTime) < FILE_ACCESS_MAX_WAIT)
  1559.      {
  1560.       /* If we were unable to open the file, call od_kernal, so that    */
  1561.       /* OpenDoors can continue to respond to sysop function keys, loss */
  1562.       /* of connection, etc.                                            */
  1563. //      od_kernal();
  1564.      }
  1565.    } else {
  1566.      fpFile = fopen(pszFileName, pszMode);
  1567.    }
  1568.  
  1569.    /* Return FILE pointer for opened file, if any. */
  1570.    return(fpFile);
  1571. }
  1572.  
  1573. FILE *ShareFileOpenAR(char *pszFileName, char *pszMode)
  1574. {
  1575.    FILE *fpFile = NULL;
  1576.    time_t StartTime = time(NULL);
  1577. //   char numstr[14];
  1578. //   ffblk ffblk;
  1579. //   ny_kernel();
  1580.  
  1581.  
  1582.    /* Attempt to open the file while there is still time remaining. */
  1583.  
  1584.    if(single_node==FALSE) {
  1585.  
  1586. /*     if(no_kernel==FALSE) {
  1587.        ny_kernel();
  1588.        sprintf(numstr,"u%07d.rnk",nCurrentUserNumber);
  1589.        if (findfirst(numstr,&fff,0)==0) {
  1590.      no_kernel=TRUE;
  1591.      fpFile=ShareFileOpen(numstr,"rb");
  1592.      ny_fread(&cur_user.rank,2,1,fpFile);
  1593.      no_kernel=FALSE;
  1594.      fclose(fpFile);
  1595.      ny_remove(numstr);
  1596.      wrt_sts();
  1597.        }
  1598.      }*/
  1599.  
  1600.      while((fpFile = fopen(pszFileName, pszMode)) == NULL
  1601.     && errno == EACCES
  1602.     && difftime(time(NULL), StartTime) < FILE_ACCESS_MAX_WAIT)
  1603.      {
  1604.       /* If we were unable to open the file, call od_kernal, so that    */
  1605.       /* OpenDoors can continue to respond to sysop function keys, loss */
  1606.       /* of connection, etc.                                            */
  1607. //      od_kernal();
  1608.      }
  1609.    } else {
  1610.      fpFile = fopen(pszFileName, pszMode);
  1611.  
  1612.    }
  1613.  
  1614.  
  1615.    /* Return FILE pointer for opened file, if any. */
  1616.    return(fpFile);
  1617. }
  1618.  
  1619.  
  1620. int
  1621. ny_remove(char *pszFileName)
  1622. {
  1623. //   FILE *fpFile = NULL;
  1624.    time_t StartTime;
  1625. //   char numstr[80];
  1626. //   ffblk ffblk;
  1627. //   ny_kernel();
  1628.  
  1629.   if(findfirst(pszFileName,&fff,0)!=0) return(0);
  1630.  
  1631.   do {
  1632.    StartTime = time(NULL);
  1633.    /* Attempt to open the file while there is still time remaining. */
  1634.    if(single_node==FALSE) {
  1635.      while(remove(fff.ff_name) == -1
  1636.     && errno == EACCES
  1637.     && difftime(time(NULL), StartTime) < FILE_ACCESS_MAX_WAIT)
  1638.      {
  1639.       /* If we were unable to open the file, call od_kernal, so that    */
  1640.       /* OpenDoors can continue to respond to sysop function keys, loss */
  1641.       /* of connection, etc.                                            */
  1642. //      od_kernal();
  1643.      }
  1644.    } else {
  1645.      remove(fff.ff_name);
  1646.    }
  1647.   } while(findnext(&fff)==0);
  1648.  
  1649.   return(1);
  1650. }
  1651.  
  1652.  
  1653.  
  1654. /* The WaitForEnter() function is used to create custom prompt */
  1655. //void
  1656. //WaitForEnter(void)
  1657. //{
  1658.    /* Display prompt. */
  1659.    //od_control.od_ker_exec=NULL;
  1660. //   ny_line(1,1,0);
  1661. //   ny_disp_emu("\n\r`@Smack [ENTER] to go on.");
  1662.  
  1663.    //od_control.od_ker_exec=ny_kernel;
  1664.  
  1665.    /* Wait for a Carriage Return or Line Feed character from the user. */
  1666. //   od_get_answer("\n\r");
  1667.  
  1668.    //debug
  1669. //   od_printf("%d\n\r",nCurrentUserNumber);
  1670. //   ny_get_answer("\n\r");
  1671. //}
  1672.  
  1673.  
  1674. /*void
  1675. ny_disp_emu(char line[])
  1676. {
  1677.   int cnt;
  1678.  
  1679.   for(cnt=0;line[cnt]!=0;cnt++) {
  1680.     if(line[cnt]=='`') {
  1681.       cnt++;
  1682.  
  1683.     if(line[cnt]==0)
  1684.       return;
  1685.     else if(line[cnt]=='`')
  1686.       od_putch('`');
  1687.     else if(line[cnt]=='v')
  1688.       od_printf(ver);
  1689.     else if(line[cnt]=='w')
  1690.       od_printf(verinfo);
  1691.     else if(line[cnt]=='0')
  1692.       od_set_attrib(0x0a);
  1693.     else if(line[cnt]=='1')
  1694.       od_set_attrib(0x01);
  1695.     else if(line[cnt]=='2')
  1696.       od_set_attrib(0x02);
  1697.     else if(line[cnt]=='3')
  1698.       od_set_attrib(0x03);
  1699.     else if(line[cnt]=='4')
  1700.       od_set_attrib(0x04);
  1701.     else if(line[cnt]=='5')
  1702.       od_set_attrib(0x05);
  1703.     else if(line[cnt]=='6')
  1704.       od_set_attrib(0x06);
  1705.     else if(line[cnt]=='7')
  1706.       od_set_attrib(0x07);
  1707.     else if(line[cnt]=='8')
  1708.       od_set_attrib(0x08);
  1709.     else if(line[cnt]=='9')
  1710.       od_set_attrib(0x09);
  1711.     else if(line[cnt]=='!')
  1712.       od_set_attrib(0x0b);
  1713.     else if(line[cnt]=='@')
  1714.       od_set_attrib(0x0c);
  1715.     else if(line[cnt]=='#')
  1716.       od_set_attrib(0x0d);
  1717.     else if(line[cnt]=='$')
  1718.       od_set_attrib(0x0e);
  1719.     else if(line[cnt]=='%')
  1720.       od_set_attrib(0x0f);
  1721.  
  1722.     } else if (line[cnt]==9) {
  1723.       od_printf("        ");
  1724.     } else {
  1725.       od_putch(line[cnt]);
  1726.     }
  1727.   }
  1728.   od_kernal();
  1729. } */
  1730.  
  1731. int
  1732. copyfile(char *file1,char *file2)
  1733. {
  1734.   FILE *f1,*f2;
  1735.   char *buffer;
  1736.   long len1,x,y;//where,x,y;
  1737.  
  1738.  
  1739.   f1=ShareFileOpen(file1,"rb");
  1740.   if(f1==NULL) return(0);
  1741.   f2=ShareFileOpenAR(file2,"wb");
  1742.   if(f2==NULL) {
  1743.     fclose(f1);
  1744.     return(0);
  1745.   }
  1746.  
  1747.   buffer=(char *)malloc(10000);
  1748.  
  1749.   len1=filelength(fileno(f1));
  1750.   x=len1/10000;
  1751.  
  1752.   for(y=0;y<x;y++) {
  1753.     ny_fread(buffer,10000,1,f1);
  1754.     ny_fwrite(buffer,10000,1,f2);
  1755.   }
  1756.  
  1757.   y=len1-(x*10000);
  1758.  
  1759.   if(y>0) {
  1760.     ny_fread(buffer,y,1,f1);
  1761.     ny_fwrite(buffer,y,1,f2);
  1762.   }
  1763.  
  1764.   fclose(f1);
  1765.   fclose(f2);
  1766.   free(buffer);
  1767.  
  1768.   return(1);
  1769. }
  1770.  
  1771.  
  1772. /* CustomConfigFunction() is called by OpenDoors to process custom */
  1773. /* configuration file keywords that                                */
  1774. /*void CustomConfigFunction(char *pszKeyword, char *pszOptions)
  1775. {
  1776.   if(stricmp(pszKeyword, "SingleNodeOnly") == 0)
  1777.   {
  1778.     single_node=TRUE;
  1779.   }
  1780.   else if(stricmp(pszKeyword, "NoMultitasker") == 0)
  1781.   {
  1782.     no_slices=TRUE;
  1783.   }
  1784.   else if(stricmp(pszKeyword, "PollingValue") == 0)
  1785.   {
  1786.     sscanf(pszOptions,"%d",&time_slice_value);
  1787.     if (time_slice_value<0) time_slice_value=0;
  1788.     if (time_slice_value>2000) time_slice_value=2000;
  1789.   }
  1790.   else if(stricmp(pszKeyword, "InterBBS") == 0)
  1791.   {
  1792.     ibbs=TRUE;
  1793.   }
  1794.   else if(stricmp(pszKeyword, "InterBBSOperator") == 0)
  1795.   {
  1796.     ibbs_operator=TRUE;
  1797.   }
  1798.   else if(stricmp(pszKeyword, "InterBBSGameNumber") == 0)
  1799.   {
  1800.     sscanf(pszOptions,"%d",&ibbs_game_num);
  1801.   }
  1802. } */
  1803.  
  1804. void
  1805. strzcpy(char dest[],const char src[], int beg,int end)
  1806. {
  1807.   int cnt=0;
  1808.   do {
  1809.     dest[cnt]=src[beg];
  1810.     beg++;
  1811.     cnt++;
  1812.   } while (cnt<=end && src[cnt]!=0);
  1813.   dest[cnt]=0;
  1814. }
  1815.